// https://iai.sh.cn/problem/532
#include <bits/stdc++.h>
using namespace std;
int a[200000];
int b[200000];
int main() {

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  int timea = a[1], timeb = a[1] + b[1];
  for (int i = 2; i <= n; i++) {
    timea += a[i];
    if (timea >= timeb) {
      timeb = timea + b[i];
    } else {
      timeb += b[i];
    }
  }
  cout << max(timea, timeb) << endl;

  return 0;
}